package Stream;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class ObjectStreamEx {
	String filename = "data.dat";
	
	public void save(){
		Score s = new Score("aaaa","hong",100,90);
		try{
			File f = new File(filename);
			FileOutputStream fos = new FileOutputStream(f);
			ObjectOutputStream oos = new ObjectOutputStream(fos);
			oos.writeObject(s);
			
			
			oos.close();
			fos.close();
			
		}catch(Exception ex){
			
		}
	}
	
	public void load(){
		try{
			File f = new File(filename);
			FileInputStream fis = new FileInputStream(f);
			ObjectInputStream ois = new ObjectInputStream(fis);
			Score o = (Score)ois.readObject();
			
			System.out.println("id:" +o.getUserID());
			System.out.println("name:" +o.getIrum());
			System.out.println("kor:" +o.getKor());
			System.out.println("eng:" +o.getEng());
			System.out.println("tot:" +o.getTot());
			
			ois.close();
			fis.close();
			
		}catch(Exception ex){
			
		}
	}
	
	public static void main(String[] args) {
		ObjectStreamEx ex = new ObjectStreamEx();
		ex.save();
		ex.load();

	}

}
